package exec;

public class Exec10 {

    public static void main(String[] args) {
        //  现有一个 int 数组，数组中有十个元素。将数组反转后输出。
        int[] arr = new int[]{9, 1, 3, 4, 54, 56, 23, 22, 20, 43};
//        for (int i = arr.length - 1; i >= 0; i--) {
//            System.out.println(arr[i]);
//        }
        for (int i = 0, j = arr.length - 1; i < arr.length / 2; i++, j--) {
//            int temp = arr[i];
//            arr[i] = arr[j];
//            arr[j] = temp;
            arr[i] = arr[i] ^ arr[j]; // 1100 0000 1100   1100  0000
            arr[j] = arr[i] ^ arr[j]; // arr[i] ^ arr[j] ^ arr[j] = arr[i] ^ 0 = arr[i]
            arr[i] = arr[i] ^ arr[j]; // arr[i] ^ arr[j] ^ arr[i] = 0 ^ arr[j] = arr[j]
        }
        for (int a : arr) {
            System.out.println(a);
        }

    }
}
